home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / Oberon⁄F™ 1.2 / Preinstalled version / System / Docu / Strings / Strings (.txt)
Encoding:
Oberon Document  |  1996-07-08  |  11.4 KB  |  175 lines  |  [oODC/obnF]

  1. Documents.StdDocumentDesc
  2. Documents.DocumentDesc
  3. Containers.ViewDesc
  4. Views.ViewDesc
  5. Stores.StoreDesc
  6. Documents.ModelDesc
  7. Containers.ModelDesc
  8. Models.ModelDesc
  9. Stores.ElemDesc
  10. TextViews.StdViewDesc
  11. TextViews.ViewDesc
  12. TextModels.StdModelDesc
  13. TextModels.ModelDesc
  14. TextModels.AttributesDesc
  15. Helvetica
  16. TextRulers.StdRulerDesc
  17. TextRulers.RulerDesc
  18. TextRulers.StdStyleDesc
  19. TextRulers.StyleDesc
  20. TextRulers.AttributesDesc
  21. Helvetica
  22. Helvetica
  23. Helvetica
  24. Strings
  25. DEFINITION Strings;
  26.     CONST
  27.         charCode = -16; decimal = 10; hexadecimal = 16;
  28.         digitspace = 8FX;
  29.     PROCEDURE  Append (VAR s: ARRAY OF CHAR; suffix: ARRAY OF CHAR);
  30.     PROCEDURE  Concat (s1, s2: ARRAY OF CHAR; VAR res: ARRAY OF CHAR);
  31.     PROCEDURE  Extract (VAR s: ARRAY OF CHAR; pos, len: LONGINT; VAR res: ARRAY OF CHAR);
  32.     PROCEDURE  Find (VAR s: ARRAY OF CHAR; pat: ARRAY OF CHAR; start: LONGINT;
  33.                                     VAR pos: LONGINT);
  34.     PROCEDURE  Len (VAR s: ARRAY OF CHAR): LONGINT;
  35.     PROCEDURE  Lower (ch: CHAR): CHAR;
  36.     PROCEDURE  Replace (VAR s: ARRAY OF CHAR; pos, len: LONGINT; rep: ARRAY OF CHAR);
  37.     PROCEDURE  ToLower (VAR in: ARRAY OF CHAR; VAR out: ARRAY OF CHAR);
  38.     PROCEDURE  ToUpper (VAR in: ARRAY OF CHAR; VAR out: ARRAY OF CHAR);
  39.     PROCEDURE  Upper (ch: CHAR): CHAR;
  40.     PROCEDURE  Valid (VAR s: ARRAY OF CHAR): BOOLEAN;
  41.     PROCEDURE  IntToString (x: LONGINT; VAR s: ARRAY OF CHAR);
  42.     PROCEDURE  IntToStringForm (x: LONGINT; form, minWidth: INTEGER; fillCh: CHAR;
  43.                                                         suffix: BOOLEAN; VAR s: ARRAY OF CHAR);
  44.     PROCEDURE  RealToString (x: REAL; VAR s: ARRAY OF CHAR);
  45.     PROCEDURE  RealToStringForm (x: LONGREAL; precision, minW, expW: INTEGER; fillCh: CHAR;
  46.                                                             VAR s: ARRAY OF CHAR);
  47.     PROCEDURE  LongRealToString (x: LONGREAL; VAR s: ARRAY OF CHAR);
  48.     PROCEDURE  StringToInt (s: ARRAY OF CHAR; VAR x, res: LONGINT);
  49.     PROCEDURE  StringToReal (s: ARRAY OF CHAR; VAR x: LONGREAL; VAR res: LONGINT);
  50. END Strings.
  51. CONST charCode
  52. Possible value for parameter form of IntToStringForm, asking for formatting integers following the syntax of Oberon numerical character literals, e.g. 0DX or 37X.
  53. CONST decimal
  54. Possible value for parameter form of IntToStringForm, asking for formatting integers as decimal literals.
  55. CONST hexadecimal
  56. Possible value for parameter form of IntToStringForm, asking for formatting integers as hexadecimal literals.
  57. CONST digitspace
  58. A digit space has the width of digit zero (0) which is equivalent to the width of all digits in most fonts, thus can be used for number formatting.
  59. PROCEDURE  Valid (VAR s: ARRAY OF CHAR): BOOLEAN;
  60. Returns TRUE if and only if the array s contains at least one string terminator 0X.
  61. s = s'
  62. s contains a valid string value =>
  63.     EXIST i, 0 <= i < LEN(s): s[i] = 0X
  64. s does not contain a valid string value =>
  65.     ALL i IN RANGE 0 .. LEN(s)-1: s[i] # 0X
  66. PROCEDURE Len (VAR s: ARRAY OF CHAR): LONGINT;
  67. Returns the position of the first occurrence of the string terminator 0X in s.
  68. Valid(s)    (not checked)
  69. s = s'
  70. 0 <= Len(s) < LEN(s)
  71. FORALL i IN RANGE [0 .. Len(s)): s[i] # 0X
  72. PROCEDURE Upper (ch: CHAR): CHAR;
  73. PROCEDURE Lower (ch: CHAR): CHAR;
  74. Conversion to uppercase and lowercase characters. Handles the entire ISO Latin-1 character set. Character values that have no uppercase or lowercase aequivalent are returned unchanged.
  75. PROCEDURE ToLower (VAR in: ARRAY OF CHAR; VAR out: ARRAY OF CHAR);
  76. Converts string in to lowercase characters and returns the result in out. Handles the entire ISO Latin-1 character set. Character values that have no lowercase equivalent are unchanged. The same actual parameter may be passed for in and out.
  77. Valid(in)    index trap
  78. Valid(out)
  79. FORALL i IN RANGE [0 .. MIN(Len(in), LEN(out)-1): out[i] = Lower(in[i])
  80. PROCEDURE ToUpper (VAR in: ARRAY OF CHAR; VAR out: ARRAY OF CHAR);
  81. Converts string in  to uppercase characters and returns the result in out. Handles the entire ISO Latin-1 character set. Character values that have no uppercase equivalent are unchanged. The same actual parameter may be passed for in and out.
  82. Valid(in)    index trap
  83. Valid(out)
  84. FORALL i IN RANGE [0 .. MIN(Len(in), LEN(out)-1): out[i] = Upper(in[i])
  85. PROCEDURE Concat (s1, s2: ARRAY OF CHAR; VAR res: ARRAY OF CHAR);
  86. Appends string s2 to s1 and returns the result in res. If res is not large enough to hold the result, the result is truncated.
  87. Valid(s1) & Valid(s2)    (not checked)
  88. Len(res) = MIN(Len(s1)+Len(s2), LEN(res)-1)
  89. FORALL i IN RANGE [0 .. MIN(Len(s1), LEN(res)-1): res[i] = s1[i]
  90. FORALL i IN RANGE [Len(s1) .. MIN(Len(s1) + Len(s2), LEN(res)-1): res[i] = s2[i-Len(s1)]
  91. PROCEDURE Append (VAR s: ARRAY OF CHAR; suffix: ARRAY OF CHAR);
  92. Appends the string suffix to s. Except for performance, Append(s, suffix) is equivalent to Concat(s, suffix, s)
  93. PROCEDURE Extract (VAR s: ARRAY OF CHAR; pos, len: LONGINT; VAR res: ARRAY OF CHAR);
  94. Extracts the stretch [pos, MIN(pos+len, Len(s))) from s and returns it in res. The result is truncated if res is not large enough. The same actual parameter may be passed for s and res.
  95. len >= 0    20
  96. pos >= 0    21
  97. Valid(s)    (not checked)
  98. Len(res) = MAX(MIN(len, Len(s')-pos, LEN(res)-1), 0)
  99. FORALL i IN RANGE [0 .. Len(res)): res[i] := s'[pos+i]
  100. PROCEDURE Replace (VAR s: ARRAY OF CHAR; pos, len: LONGINT; rep: ARRAY OF CHAR);
  101. Replaces the stretch [pos, MIN(pos+len, Len(s))) in s with the string in rep. The characters after the replaced stretch are moved if necessary. The result is truncated if s is not large enough.
  102. len >= 0    20
  103. pos >= 0    21
  104. Valid(s) & Valid(rep)    (not checked)
  105. Valid(res)
  106. FORALL i IN RANGE [0 .. MIN(pos, Len(s')): s[i] := s'[i]
  107. FORALL i IN RANGE [pos .. MIN(pos+Len(rep), LEN(s)-1): s[i] = rep[i-pos]
  108. FORALL i IN RANGE [pos+Len(rep) .. MIN(Len(s')-len+Len(rep), LEN(s) -1): s[i] := s'[i+len-Len(rep)]
  109. Hint: if len = 0 then rep is inserted in s at position pos. If Len(rep) = 0 then the stretch [pos, MIN(pos+len, Len(s))) is deleted from s.
  110. PROCEDURE Find (VAR s: ARRAY OF CHAR; pat: ARRAY OF CHAR; start: LONGINT;
  111.                                     VAR pos: LONGINT);
  112. Searches the first occurrence of the pattern pat in string s after position start. If the pattern is found, the position of the first character of the pattern in s is returned in pos. If the pattern is not found, pos is -1.
  113. start >= 0    20
  114. Valid(s) & Valid(pat)    (not checked)
  115. s = s'
  116. (* Match(pos) == FORALL i IN RANGE [0 .. Len(pat)): s[i+pos] = pat[i] *)
  117. pos = -1 =>
  118.     FORALL i IN RANGE [start, Len(s)-Len(pat)]: ~Match(i)
  119.     start > Len(s)-Len(pat)
  120. start <= pos <= Len(s)-Len(pat)  =>
  121.     Match(pos)
  122.         AND
  123.     FORALL i IN RANGE [start .. pos): ~Match(i)
  124. PROCEDURE  IntToStringForm (x: LONGINT; form, minWidth: INTEGER; fillCh: CHAR;
  125.                             suffix: BOOLEAN; VAR s: ARRAY OF CHAR);
  126. Convert integer x into string s. If form is charCode or hexadecimal, x is converted to a base 16 representation. The total representation will at least have a width of minWidth characters, where padding (if required) takes place to the left using characters as specified by fillCh.
  127. If suffix is TRUE, a suffix character is appended to the number representation according to the number form. The value form = charCode renders the suffix "X", while form = hexadecimal renders the suffix "H".
  128. decimal representations of negative integers are formed using a base
  129. complement form of width minWidth. E.g., x = -3 renders for base = 16 and minWidth = 4 as "FFFD".
  130. (form = charCode) OR (form = decimal) OR (form = hexadecimal)    20
  131. minWidth >= 0    22
  132. PROCEDURE IntToString (x: LONGINT; VAR s: ARRAY OF CHAR)
  133. Write integer in default format. Except for performance, equivalent to:
  134.     IntToStringForm(x, decimal, 0, digitspace, TRUE, s)
  135. PROCEDURE RealToStringForm (x: LONGREAL; precision, minW, expW: INTEGER;
  136.                             fillCh: CHAR; VAR s: ARRAY OF CHAR);
  137. Convert real x into string s. The string created to represent the number is either in fixed point or in scientific format, according to expW. precision denotes the number of valid decimal places (usually 7 for reals and 16 for long reals). minW denotes the minimal length in characters. If necessary, preceding fillCh will be inserted. Numbers are always rounded to the last valid and visible digit.
  138. expW > 0: exponential format (scientific) with at least expW digits in the exponent.
  139. expW = 0: fixpoint or floatingpoint format, depending on x.
  140. expW < 0: fixpoint format with -expW digits after the decimal point.
  141. 0 < precision <= 16    20
  142. 0 <= minW < LEN(s)    21
  143. -LEN(s) < expW <= 3    22
  144. PROCEDURE RealToString (x: REAL; VAR s: ARRAY OF CHAR)
  145. Write real in default format. Except for performance, equivalent to:
  146.     RealToStringForm(x, 7, 0, 0, digitspace, s)
  147. PROCEDURE LongRealToString (x: LONGREAL; VAR s: ARRAY OF CHAR)
  148. Write long real in default format. Except for performance, equivalent to:
  149.     RealToStringForm(x, 16, 0, 0, digitspace)
  150. PROCEDURE StringToInt (s: ARRAY OF CHAR; VAR x: LONGINT; VAR res: LONGINT)
  151. Converts the number contained in string s into value x. Legal integer number representations follow the syntax given below. Possible result codes are res = 1 for overflow, res = 2 for syntax error.
  152. $ number = ( [ "+" | "-" ] dec | hex ) 0X .
  153. $ dec = digit { digit } .
  154. $ hex = hexdigit { hexdigit } ("H" | "X") .
  155. $ hexdigit = digit | "A" | "B" | "C" | "D" | "E" | "F" .
  156. $ digit = "0" |  "1" |  "2" |  "3" |  "4" |  "5" |  "6" |  "7" |  "8" |  "9" .
  157. s is legal integer number representation
  158.     x is converted real number
  159.     res = 0
  160. s is not a legal integer number representation
  161.     res # 0
  162. PROCEDURE StringToReal (s: ARRAY OF CHAR; VAR x: LONGREAL; VAR res: LONGINT)
  163. Converts string s given in fixed or scientific notation into value x. Possible result codes are res = 1 for overflow, res = 2 for syntax error.
  164. s is legal real number representation
  165.     x is converted real number
  166.     res = 0
  167. s is not legal real number representation
  168.     res # 0
  169. TextControllers.StdCtrlDesc
  170. TextControllers.ControllerDesc
  171. Containers.ControllerDesc
  172. Controllers.ControllerDesc
  173. Arial
  174. Documents.ControllerDesc
  175.